package com.leoman.plz_p.utils;

import android.os.Build;

import com.leoman.plz_p.module.bean.User;

import cn.com.corelib.utils.PreferencesHelper;

/**
 * Created by guoh on 2018/7/15.
 */
public class UserHelper {

    private static final String mDevID = "35" +
            Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 + Build.DISPLAY.length() % 10 + Build.HOST.length() % 10 + Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10 + Build.TAGS.length() % 10 + Build.TYPE.length() % 10 + Build.USER.length() % 10;

    public static String getmDevID(){
        return mDevID;
    }

    public static void saveUser(User user){
        PreferencesHelper.saveData(user);
    }

    public static User getSavedUser(){
        User user = PreferencesHelper.getData(User.class);
        return user;
    }

    public static String getToken(){
        User user = getSavedUser();
        if (user!=null)
            return user.getToken();
        else
            return "";
    }

    public static long getUserId(){
        User user=getSavedUser();
        if (user!=null)
            return user.getId();
        else
            return 0;
    }

    public static void clear(){
        PreferencesHelper.remove(User.class);
    }

}
